<template>
  <div class="home container">
    <alert v-if="alert" v-bind:message="alert"></alert>
         <h1>用户管理系统</h1>
         <table class="table table-striped">
              <thead>
                <tr>
                  <th>姓名</th>
                  <th>电话</th>
                  <th>邮箱</th>
                  <th></th>
                </tr>
              </thead>
              <tbody>
                <tr v-for="(item,index) in listnav" :key="index">
                  <td>{{item.name}}</td>
                  <td>{{item.phone}}</td>
                  <td>{{item.email}}</td>
                  <td><router-link class="btn btn-default" to="'/xq/'">详情</router-link> </td>
                </tr>
              </tbody>
           
            </table>
   
  </div>
</template>

<script>


import axios from 'axios'
import alert from "./Alert"


export default {
  name: 'Home',
  components:{
    alert,
  },

  data(){
       return{
         listnav:[],
         alert:""
       }

  },
 
  created(){
    if(this.$route.query.alert){
      this.alert=this.$route.query.alert
    }
        this.fechcustomr()
  },
      updated(){

          this.fechcustomr()
      },
   methods:{
             fechcustomr(){
               axios({
               url:'http://localhost:8082/users',
                method:'get',
           
    }).then(res=>{
        
     this.listnav=res.data
     
     

    })

             }

   }
}
</script>
